sap.ui.define([
   "sap/ui/core/mvc/Controller",
   'sap/m/library',
   'sap/ui/model/json/JSONModel',
   "sap/ui/core/format/DateFormat",
], function (
   Controller,
   mobileLibrary,
   JSONModel,
   DateFormat,
) {
   "use strict";

   var ExpandableTextOverflowMode = mobileLibrary.ExpandableTextOverflowMode;

   return Controller.extend("autofiror.controller.Overview", {
      onInit: function (oEvent) {

         let mod = {
            overflowMode: ExpandableTextOverflowMode.Popover
         }

         var oMod = new JSONModel(mod);
         this.getView().setModel(oMod, 'mod');
      },

      onButtonOpenDialogPress() {
         // 判断是否有pDialog这个变量
         this.pDialog ??= this.loadFragment({
            name: "autofiror.view.menu.HelloDialog",
            Controller: this
         });
         this.pDialog.then((oDialog) => oDialog.open());
      },

      onCloseTheDialog() {
         this.byId("helloDialog").close();
      },

      onPost: function (oEvent) {
         var oFormat = DateFormat.getDateTimeInstance({ style: "medium" });
         var oDate = new Date();
         var sDate = oFormat.format(oDate);
         // create new entry
         var sValue = oEvent.getParameter("value");
         var oEntry = {
            Author: "Alexandrina Victoria",
            AuthorPicUrl: "test-resources/sap/m/images/dronning_victoria.jpg",
            Type: "Reply",
            Date: "" + sDate,
            Text: sValue
         };

         // update model
         var oModel = this.getView().getModel('info');
         let list = oModel.oData.feedList;
         list.unshift(oEntry);
         oModel.setData({
            ...oModel.oData,
				feedList: list
			});
      },

      onSenderPress: function (oEvent) {
         MessageToast.show("Clicked on Link: " + oEvent.getSource().getSender());
      },

      onIconPress: function (oEvent) {
         MessageToast.show("Clicked on Image: " + oEvent.getSource().getSender());
      },

      fatherPressButton: function() {
         console.log("fatherPressButton");
      },

      fatherPressButtonWithPar: function(value) {
         console.log("fatherPressButtonWithPar");
         console.log(value);
         console.log(value.mParameters);
      },

   });
});